package com.hgxd.controller;

import com.hgxd.annotation.OperationLogAnnotation;
import com.hgxd.entity.pojo.OnOrOff;
import com.hgxd.result.Result;
import com.hgxd.service.OnOrOffService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @Author: wtf
 * @Description: 开合闸列表
 * @Date: 2022/10/20/11:21
 */
@Api(tags = "开合闸及故障")
@RestController
@CrossOrigin
@RequestMapping("api/onOrOff")
public class OnOrOffController {
    @Resource(name = "OnOrOffService")
    private OnOrOffService onOrOffService;

    /**
     * 根据柜号查询对应柜体的状态
     *
     * @return
     */
    @ApiOperation(value = "根据柜号查询对应柜体的状态",notes = "必须传参柜号（cntrNo）")
    @OperationLogAnnotation(operModule = "开合闸及故障模块-根据柜号查询对应柜体的状态",operType = "查询",operContent = "根据柜号查询对应柜体的状态")
    @GetMapping("getStatusByCntrNo/{cntrNo}")
    public Result<List<OnOrOff>> getStatusByCntrNo(@PathVariable("cntrNo") String cntrNo) {
        return Result.ok(onOrOffService.getStatusByCntrNo(cntrNo));
    }


    /**
     * 获取所有柜体的所属从机状态
     *
     * @return
     */
    @ApiOperation(value = "获取所有柜体的所属从机状态",notes = "无需传参")
    @OperationLogAnnotation(operModule = "开合闸及故障模块-获取所有柜体的所属从机状态",operType = "查询",operContent = "获取所有柜体的所属从机状态")
    @GetMapping("getAllStatus")
    public Result<Map<String, List<OnOrOff>>> getAllStatus() {
        return Result.ok(onOrOffService.getAllStatus());
    }


    /**
     * 查询全部开合闸
     *
     * @return
     */
    @ApiOperation(value = "查询全部开合闸",notes = "无需传参")
    @OperationLogAnnotation(operModule = "开合闸及故障模块-查询全部开合闸",operType = "查询",operContent = "查询全部开合闸")
    @GetMapping("getAll")
    public Result<List<OnOrOff>> getAll() {
        return Result.ok(onOrOffService.list());
    }

}
